<!--
OpenWPFChart library ChartLegend control default style.
Copyright Oleg V. Polikarpotchkin 2008-2009
-->
<!--revision $Id$-->
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:parts="clr-namespace:OpenWPFChart.Parts;assembly=OpenWPFChart.Parts"
    xmlns:local="clr-namespace:OpenWPFChart.Controls">
	
	<!-- Chart Control Style -->
	<Style TargetType="{x:Type local:ChartLegend}">
		<Style.Resources>
			<!-- Legend Items Templates -->
			<DataTemplate DataType="{x:Type parts:SampledCurveDataView}">
				<Grid Margin="3" ShowGridLines="False">
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="Auto" SharedSizeGroup="ItemName"/>
						<ColumnDefinition Width="30"/>
						<ColumnDefinition Width="Auto" SharedSizeGroup="PointMarker"/>
					</Grid.ColumnDefinitions>

					<TextBlock Text="{Binding Path=ItemData.ItemName}" VerticalAlignment="Center"/>
					<Rectangle Grid.Column="1" 
						Fill="{Binding Path=Pen.Brush}" Height="2"
						VerticalAlignment="Center" HorizontalAlignment="Stretch"
						Margin="5"/>
					<Image Grid.Column="2" Stretch="None" HorizontalAlignment="Left" VerticalAlignment="Center">
						<Image.Source>
							<DrawingImage>
								<DrawingImage.Drawing>
									<Binding Path="PointMarker"/>
								</DrawingImage.Drawing>
							</DrawingImage>
						</Image.Source>
					</Image>
				</Grid>
			</DataTemplate>
			<DataTemplate DataType="{x:Type parts:CurveDataView}">
				<Grid Margin="3" ShowGridLines="False">
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="Auto" SharedSizeGroup="ItemName"/>
						<ColumnDefinition Width="30"/>
					</Grid.ColumnDefinitions>

					<TextBlock Text="{Binding Path=ItemData.ItemName}" VerticalAlignment="Center"/>
					<Border Grid.Column="1" 
						BorderBrush="{Binding Path=Pen.Brush}" BorderThickness="2"
						VerticalAlignment="Center" HorizontalAlignment="Stretch"
						Margin="5"/>
				</Grid>
			</DataTemplate>
			<DataTemplate DataType="{x:Type parts:ScatteredPointsDataView}">
				<Grid Margin="3" ShowGridLines="False">
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="Auto" SharedSizeGroup="ItemName"/>
						<ColumnDefinition Width="Auto" SharedSizeGroup="PointMarker"/>
					</Grid.ColumnDefinitions>

					<TextBlock Text="{Binding Path=ItemData.ItemName}" VerticalAlignment="Center"/>
					<Image Grid.Column="1" Margin="5" Stretch="None" 
						   HorizontalAlignment="Left" VerticalAlignment="Center">
						<Image.Source>
							<DrawingImage>
								<DrawingImage.Drawing>
									<Binding Path="PointMarker"/>
								</DrawingImage.Drawing>
							</DrawingImage>
						</Image.Source>
					</Image>
				</Grid>
			</DataTemplate>			
			<DataTemplate DataType="{x:Type parts:BubblePointsDataView}">
				<Grid Margin="3" ShowGridLines="False">
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="Auto" SharedSizeGroup="ItemName"/>
						<ColumnDefinition Width="Auto" SharedSizeGroup="PointMarker"/>
					</Grid.ColumnDefinitions>

					<TextBlock Text="{Binding Path=ItemData.ItemName}" VerticalAlignment="Center"/>
					<Image Grid.Column="1" Margin="5" Stretch="None" 
						   HorizontalAlignment="Left" VerticalAlignment="Center">
						<Image.Source>
							<DrawingImage>
								<DrawingImage.Drawing>
									<Binding Path="Bubble"/>
								</DrawingImage.Drawing>
							</DrawingImage>
						</Image.Source>
					</Image>
				</Grid>
			</DataTemplate>			
			<DataTemplate DataType="{x:Type parts:ItemDataView}">
				<TextBlock Text="{Binding Path=ItemData.ItemName}" VerticalAlignment="Center" Margin="3"/>
			</DataTemplate>
		</Style.Resources>
		
		<Setter Property="Grid.IsSharedSizeScope" Value="True"/>
		
		<!-- ChartLegend Control Template -->
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type local:ChartLegend}">
					<Border Name="Bd"
							BorderThickness="{TemplateBinding Border.BorderThickness}" 
							BorderBrush="{TemplateBinding Border.BorderBrush}" 
							CornerRadius="{TemplateBinding Border.CornerRadius}" 
							Background="{TemplateBinding Panel.Background}" 
							SnapsToDevicePixels="True">
						<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"
								Padding="{TemplateBinding Control.Padding}" Focusable="False">
							<StackPanel>
								<!-- Legend Title -->
								<TextBlock Text="{TemplateBinding Title}" Margin="3" FontWeight="Bold"/>
								<!-- Legend items -->
								<ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
							</StackPanel>
						</ScrollViewer>
					</Border>
					
					<ControlTemplate.Triggers>
						<Trigger Property="UIElement.IsEnabled">
							<Trigger.Value>
								<sys:Boolean>False</sys:Boolean>
							</Trigger.Value>
							<Setter Property="Panel.Background" TargetName="Bd">
								<Setter.Value>
									<DynamicResource ResourceKey="{x:Static SystemColors.ControlBrushKey}" />
								</Setter.Value>
							</Setter>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
</ResourceDictionary>
